/*
 * @FilePath: /app/common/strlist.cpp
 * @Author: Wilson
 * @Descripttion: 
 * @Date: 2021-08-19 23:21:32
 * @LastEditors: Wilson
 * @LastEditTime: 2021-08-19 23:26:56
 */
#include "strlist.h"

namespace util
{
    std::list<int> stringtolist(std::string str, std::string pattern)
    {
        std::list<int> dataList;

        std::string::size_type pos;
        str += pattern;
        int size = str.size();
        for (int i = 0; i < size; i++)
        {
            pos = str.find(pattern, i);
            if (pos < size)
            {
                std::string s = str.substr(i, pos - i);
                dataList.push_back(atoi(s.c_str()));
                i = pos + pattern.size() - 1;
            }
        }
        return dataList;
    }
}
